<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>js中的JSON对象</title>
</head>
<body>
<script>
  //定义JSON对象
  var jsonObj = {
    "name":'张三',
    "age":18,
    "hobby":['篮球','足球','羽毛球'],
    "action":function (){
        console.log('json对象中的方法1')
    }
  }
  //定义字符串
  var str = '{"name":"张三","age":18,"hobby":["篮球","足球","羽毛球"]}';
  //相互转化
  var  v1 = JSON.parse(str);
  var v2 = JSON.stringify(jsonObj);
</script>
</body>
</html>